from api import log
from config import HOST

class ApiRecharge:
    def __init__(self,session):
        # 获取session
        self.session = session
        # 充值验证码url
        self.__url_code = HOST + "/common/public/verifycode/{}"
        # 后台充值 url
        self.__url_recharge = HOST + "/trust/trust/recharge"

    #充值验证码接口 封装
    def api_img_code(self, random):
        log.info("正在调用充值验证码接口，请求方法get，请求URL：{}".format(self.__url_code.format(random)))
        return self.session.get(url=self.__url_code.format(random))

    #后台充值接口 封装
    def api_recharge(self):
        data={
            "paymentType": "chinapnrTrust",
            "amount": 10000,
            "formStr": "reForm",
            "valicode": "8888"
        }
        log.info("正在调用后台充值接口，请求方法post，请求URL：{},请求参数：{}".format(self.__url_recharge,data))
        return self.session.post(url=self.__url_recharge,data=data)
